//    Copyright (C) Kherty.  All rights reserved.
using System.Diagnostics;
using OpenLS.Spreadsheet.Formats.Biff.Tokens;

namespace OpenLS.Spreadsheet.Formats.Biff
{
    internal sealed class FormulaTokenReader
    {
        private readonly FormulaReadContext _context;

        public FormulaTokenReader(FormulaReadContext context)
        {
            _context = context;
        }

        public FormulaToken ReadToken()
        {
#if DEBUG
            FormulaTokenFactory.TestTokens();
#endif
            var id = (FormulaTokenId) _context.Reader.ReadByte();
            FormulaToken result = FormulaTokenFactory.GetToken(id);
           // Debug.WriteLine("Token = " + result);
#if DEBUG
            result.AssertReadWrite(_context);
#endif
            result.ReadContent(_context);
            return result;
        }
    }
}